package Tasks;

import AI.AiEntity;
import Constructions.Construction;
import Constructions.Morgue;
import Items.Corpse;
import Items.Item;
import Main.SpaceGame;

public class DisposeOfItem extends Task
{
	private Item item;
	private Construction disposer;
	
	public DisposeOfItem(Item i, SpaceGame main, Construction disposer)
	{
		currentStep = 0;
		urgency = 1;
		this.item = i;
		this.disposer = disposer;
		stepList.add(new PickUpItem(i, main));
		stepList.add(new Movement(disposer.workingTile.getX(), disposer.workingTile.getY()));
		System.out.println("Task Added");
	}

	@Override
	public void performTask(AiEntity e) 
	{
		if(stepList.get(currentStep).isFinished(e))
			currentStep++;
		if(currentStep < stepList.size())
		{
			stepList.get(currentStep).performTask(e);
		}
		else
		{
			if(item instanceof Corpse)
			{
				if(disposer instanceof Morgue)
					((Morgue) disposer).nameList.add(item.getText());
			}
			e.inventory.remove(item);
			finished = true;
		}
	}

	@Override
	public boolean isFinished(AiEntity e) 
	{
		return finished;
	}
}
